<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" th:href="@{/css/creation/creationmain.css}" >
    <link rel="stylesheet" th:href="@{/css/creation/form.css}" >
    <link rel="stylesheet" th:href="@{/css/creation/Dialog.css}" >
    <script src='https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js'></script>
    <script src='/js/creation/Dialog.js'></script>
    <title>创作</title>
</head>
<body>
    <div id="contain1">
        <div id="main" action="">
            <form  id="textform" onsubmit="return false;" >
                <div id="theme">
                    <label id="themelabel">主题</label>
                    <input id="themeinput" type="text" value="" placeholder="请输入主题">
                </div>
                <div id="textmain">
                    <label id="textmainlabel">正文</label>
                    <textarea id="textareamain" cols="50" value="" placeholder="请输入正文" class="form-textarea">
                    </textarea>
                </div>

                <div class="dialog" id="delallpartdialog2">
                    <div class="title">
                    </div>
                    <div class="content">
                        <img alt="" src="/img/creation/tips.png" width="60px" height="60px">
                        <span id="span2"></span>
                    </div>
                    <div class="bottom">
                        <input type="button" id="deletebut2" value="确定" >
                    </div>
                </div>

                <div id="select">
                    <div id="comment">
                        <input type="checkbox" class="check-box" id="ablecomment" checked="checked">
                        <label id="commentlabel">允许评论</label>
                    </div>
                    <div id="permission">
                        <label id="view" >访问权限:</label>
                        <input type="radio"  id="public" name="public" value="public"  checked="checked"><label id="publiclabel">公开</label>
                        <input type="radio" id="private"  name="public" value="myself"><label id="myselflabel">我自己</label>
                    </div>
                    <div id="type">
                        <label id="typelabel">移动随笔:</label>
                        <input type="radio" name="typeselect" value="yuanwen" checked="checked"><label id="yuanwentype">园文</label>
                        <input type="radio" id="note" name="typeselect" value="note"><label id="notetype">笔记</label>
                        <input type="radio" id="diary" name="typeselect" value="diary"><label id="diarytype">日记</label>
                    </div>
                    <div id="buttonbox">
                        <input type="button" class="buttonboxs" id="upload" onclick="uploadform('发布')" value="发布">
                        <input type="submit" class="buttonboxs" id="draft" onclick="uploadform('草稿')" value="存为草稿">
                        <input type="submit" class="buttonboxs" id="cancel" value="取消">
                    </div>
                </div>
            </form>
        </div>
    </div>
<script>
    var titleval="[[${titleval}]]";
    var contentval="[[${contentval}]]";
    $('#themeinput').val(titleval);
    $('#textareamain').val(contentval);
    function uploadform(Statuss) {
        articletmeme=$('#themeinput').val();
        textmain=$('#textareamain').val();
        commentflag="false";
        permiss="public";
        articletype="园文";
        articlestatus=Statuss;
        time=new Date();
        articleid="111";
        user="222";
        if($('#private').is(':checked')){
            permiss="private";
        }
        if($('#note').is(':checked')){
            articletype="笔记";
        }
        if($('#diary').is(':checked')){
            articletype="日记";
        }
        if($('#ablecomment').is(':checked')){
            commentflag="true";
        }
        var yuanwen={
            objectid:articleid,
            ywtype:articletype,
            userid:user,
            status:articlestatus,
            createtime:time.toLocaleString(),
            title:articletmeme,
            content:textmain,
            yuanwencol:permiss,
            opencomments:commentflag,
            original:true
        }
        jsonyuanwen=JSON.stringify(yuanwen);
        console.log(permiss);
        console.log(articletmeme);
        console.log(textmain);
        console.log(commentflag);
        $.ajax({
            url:"/yuanwen/writeyuanwen",
            type:"post",
            data:jsonyuanwen,
            contentType:"application/json",
            success: function (data) {
                $("#span2").text(data);
                $("#delallpartdialog2").css("display", "block");
                $('#themeinput').val(null);
                $('#textareamain').val(null);
            }
        })
    }
</script>
</body>
</html>